package demo1;

public class Test {
    public static void dp(Shape shape3){
        shape3.draw();
    }
    public static void main(String[]args){
        Rect rect=new Rect();
        Cycle cycle=new Cycle();
        Shape[] shapes={rect,cycle,rect,cycle};
        for(Shape shape1:shapes){//第一种打印方法减少圈复杂度
            shape1.draw();
        }
        //第二种打印方法
        for(int i=0;i< shapes.length;i++){
            Shape shape=shapes[i];
            shape.draw();
        }
       Shape shape3=cycle;//向上转型
        String[] strings={"cycle","rect","cycle","rect"};
        for(String s:strings){//第三种圈复杂度可能比较高的打印方法
        if(s.equals("cycle")){
            cycle.draw();
        }else {
            rect.draw();
        }
        }
       /* Shape shape1=new Shape() ;抽象类不能实例化对象其它普通父类可做的它都能做*/
        Shape shape2=new Rect();
        shape2.draw();//向上转型为抽象类父类第一种方法
        Rect rect1=new Rect();
        dp(rect1);//向上转型为抽象类的父类
        dp(cycle);
        rect1.draw();
        dp(new Rect());//新实例化对象传过去
        new Rect().draw();//新实例化对象访问
    }
}
